home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Python 1.4 / Python 1.4 source / Mac / scripts / fullbuild.py < prev    next >
Encoding:
Python Source  |  1996-10-23  |  3.9 KB  |  159 lines  |  [TEXT/Pyth]

  1. #
  2. # fullbuild creates everything that needs to be created before a
  3. # distribution can be made, and puts it all in the right place.
  4. #
  5. # It expects the projects to be in the places where Jack likes them:
  6. # in directories named like 'build.macppc.shared'. That is fixable,
  7. # however.
  8. #
  9. # NOTE: You should proably make a copy of python with which to execute this
  10. # script, rebuilding running programs does not work...
  11.  
  12. import os
  13. import sys
  14. import macfs
  15. import MacOS
  16. import EasyDialogs
  17.  
  18. import addpack
  19. import aetools
  20. import AppleEvents
  21. from Metrowerks_Shell_Suite import Metrowerks_Shell_Suite
  22. from Required_Suite import Required_Suite 
  23.  
  24. addpack.addpack('Mac')
  25. addpack.addpack('scripts')
  26. import mkapplet
  27.  
  28. class MwShell(aetools.TalkTo, Metrowerks_Shell_Suite, Required_Suite):
  29.     pass
  30.  
  31. RUNNING=[]
  32.  
  33. def buildmwproject(top, creator, projects):
  34.     """Build projects with an MW compiler"""
  35.     mgr = MwShell(creator, start=1)
  36.     mgr.send_timeout = AppleEvents.kNoTimeOut
  37.     
  38.     for file in projects:
  39.         file = os.path.join(top, file)
  40.         fss = macfs.FSSpec(file)
  41.         print 'Building', file
  42.         mgr.open(fss)
  43.         try:
  44.             mgr.Make_Project()
  45.         except aetools.Error, arg:
  46.             print '** Failed:', arg
  47.         mgr.Close_Project()
  48. ##    mgr.quit()
  49.     
  50. def buildapplet(top, dummy, list):
  51.     """Create a PPC python applet"""
  52.     template = mkapplet.findtemplate()
  53.     for src in list:
  54.         if src[-3:] != '.py':
  55.             raise 'Should end in .py', src
  56.         base = os.path.basename(src)
  57.         dst = os.path.join(top, base)[:-3]
  58.         src = os.path.join(top, src)
  59.         try:
  60.             os.unlink(dst)
  61.         except os.error:
  62.             pass
  63.         print 'Building applet', dst
  64.         mkapplet.process(template, src, dst)
  65.  
  66. #
  67. # The build instructions. Entries are (routine, arg, list-of-files)
  68. # XXXX We could also include the builds for stdwin and such here...
  69. PPC_INSTRUCTIONS=[
  70.     (buildmwproject, "CWIE", [
  71.         ":build.macppc.shared:PythonCorePPC.µ",
  72.         ":build.macppc.shared:PythonPPC.µ",
  73.         ":build.macppc.shared:PythonAppletPPC.µ",
  74.     ])
  75. ]
  76. CFM68K_INSTRUCTIONS=[
  77.     (buildmwproject, "CWIE", [
  78.         ":build.mac68k.shared:PythonCoreCFM68K.µ",
  79.         ":build.mac68k.shared:PythonCFM68K.µ",
  80.         ":build.mac68k.shared:PythonAppletCFM68K.µ",
  81.     ])
  82. ]
  83. FAT_INSTRUCTIONS=[
  84.     (buildmwproject, "CWIE", [
  85.         ":build.macppc.shared:Python.µ",
  86.         ":build.macppc.shared:PythonApplet.µ",
  87.     ])
  88. ]
  89. PLUGIN_INSTRUCTIONS=[
  90.     (buildmwproject, "CWIE", [
  91.         ":PlugIns:ctb.ppc.µ",
  92.         ":PlugIns:imgmodules.ppc.µ",
  93.         ":PlugIns:macspeech.ppc.µ",
  94.         ":PlugIns:toolboxmodules.ppc.µ",
  95.         ":PlugIns:qtmodules.ppc.µ",
  96.         ":PlugIns:waste.ppc.µ",
  97.         ":PlugIns:_tkinter.ppc.µ",
  98.     ])
  99. ]
  100. CFM68KPLUGIN_INSTRUCTIONS=[
  101.     (buildmwproject, "CWIE", [
  102.         ":PlugIns:ctb.CFM68K.µ",
  103.         ":PlugIns:imgmodules.CFM68K.µ",
  104.         ":PlugIns:toolboxmodules.CFM68K.µ",
  105.         ":PlugIns:qtmodules.CFM68K.µ",
  106.         ":PlugIns:waste.CFM68K.µ",
  107.         ":PlugIns:_tkinter.CFM68K.µ",
  108.     ])
  109. ]
  110. M68K_INSTRUCTIONS=[
  111.     (buildmwproject, "CWIE", [
  112.         ":build.mac68k.stand:Python68K.µ",
  113.     ])
  114. ]
  115. PPCSTAND_INSTRUCTIONS=[
  116.     (buildmwproject, "CWIE", [
  117.         ":build.macppc.stand:PythonStandalone.µ",
  118.     ])
  119. ]
  120. APPLET_INSTRUCTIONS=[
  121.     (buildapplet, None, [
  122.         ":Mac:scripts:EditPythonPrefs.py",
  123.         ":Mac:scripts:mkapplet.py",
  124.         ":Mac:scripts:MkPluginAliases.py"
  125.     ])
  126. ]
  127.  
  128. ALLINST=[
  129.     ("PPC shared executable", PPC_INSTRUCTIONS),
  130.     ("PPC plugin modules", PLUGIN_INSTRUCTIONS),
  131.     ("CFM68K shared executable", CFM68K_INSTRUCTIONS),
  132.     ("CFM68K plugin modules", CFM68KPLUGIN_INSTRUCTIONS),
  133.     ("FAT shared executables", FAT_INSTRUCTIONS),
  134.     ("68K standalone executable", M68K_INSTRUCTIONS),
  135.     ("PPC standalone executable", PPCSTAND_INSTRUCTIONS),
  136.     ("Applets", APPLET_INSTRUCTIONS)
  137. ]
  138.                 
  139. def main():
  140.     dir, ok = macfs.GetDirectory('Python source folder:')
  141.     if not ok:
  142.         sys.exit(0)
  143.     dir = dir.as_pathname()
  144.     INSTRUCTIONS = []
  145.     for string, inst in ALLINST:
  146.         answer = EasyDialogs.AskYesNoCancel("Build %s?"%string, 1)
  147.         if answer < 0:
  148.             sys.exit(0)
  149.         if answer:
  150.             INSTRUCTIONS = INSTRUCTIONS + inst
  151.     for routine, arg, list in INSTRUCTIONS:
  152.         routine(dir, arg, list)
  153.     print "All done!"
  154.     sys.exit(1)    
  155.     
  156. if __name__ == '__main__':
  157.     main()
  158.     
  159.